<template>
  <div>
    <h3>登录界面</h3>
    <form name="loginForm">
      <p>手机号：<input name="phoneNumber" type="text"></p>
      <p>密&nbsp;&nbsp;&nbsp;码：<input name="password" type="password"></p>
      <button @click.prevent="login">登录</button>
    </form>
  </div>
</template>

<script>
export default {
  name: "Login",
  methods: {
    async login () {
      const phoneNumber = document.loginForm.phoneNumber.value.trim();
      const password = document.loginForm.password.value.trim();
      await this.$store.dispatch('loginSync', {
        phoneNumber,
        password
      });
      const cb = this.$route.query.cb || '/';
      this.$router.push(cb)
    }
  }
}
</script>

<style scoped>
</style>